//
//  ViewFactor.m
//  Pods
//
//  Created by YangMean on 2020/8/12.
//

#import "ComponentFactory.h"
#import "JAdvModel.h"
#import <SDCycleScrollView/SDCycleScrollView.h>
#import <XHLaunchAd/XHLaunchAd.h>


#define  WIDTH    [UIScreen mainScreen].bounds.size.width
#define WidthScale(number) ([UIScreen mainScreen].bounds.size.width/375.*(number))


static NSArray *imagesURLStrings;

static ComponentFactory *viewFactor;
  
@interface ComponentFactory()<SDCycleScrollViewDelegate>{
 
}
@end
 
@implementation ComponentFactory

+ (UIView *)createAdComponentWithAdType:(NSInteger)Type{

   viewFactor = [[ComponentFactory alloc] init];
   
//    if (Type == slider) {
    SDCycleScrollView *cycleScrollView  = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0,50,WIDTH, WidthScale(150))  delegate:viewFactor placeholderImage:[UIImage imageNamed:@"123456"]];
        
        cycleScrollView.imageURLStringsGroup = @[@"https://imgcdn-prd.pydp888.com/3/block/f4/f455d98065b583267d315114211a71da.jpg",@"https://imgcdn-prd.pydp888.com/3/block/ca/ca43a4a020db13939d529fa411933c95.jpg"];
        cycleScrollView.autoScrollTimeInterval = 3.0;
        if (cycleScrollView.imageURLStringsGroup.count==1) {
            cycleScrollView.autoScroll = NO;
         }
        cycleScrollView.backgroundColor =[UIColor redColor];
        cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
        cycleScrollView.pageDotColor = [UIColor lightGrayColor];
        return cycleScrollView;

//    }else if (advType == splash) {
//       [XHLaunchAd setLaunchSourceType:SourceTypeLaunchImage];
//        XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration defaultConfiguration];
//        imageAdconfiguration.imageNameOrURLString  = @"https://imgcdn-prd.pydp888.com/3/block/ca/ca43a4a020db13939d529fa411933c95.jpg";
//
////        imageAdconfiguration.openModel  = detail.list.url;
////         imageAdconfiguration.duration   = 10;
//        [XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:viewFactor];
//    }
//      return nil;
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    NSLog(@"%ld",(long)index);

}



-(void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenModel:(id)openModel clickPoint:(CGPoint)clickPoint{
    NSLog(@"aaaa");
}


- (void)updateUI{
    //    JHomeUiInfo *homeUiInfo = [[BizHomeMain getInstance].pControlApp getHomeUiInfo];
    //    homeData  = homeUiInfo.homeDataModel;
//    NSMutableArray *picArr = [NSMutableArray new];
//    redirectUrlArr = [NSMutableArray new];
//
//    NSMutableArray *data =(NSMutableArray *) _homeModel;
//    [data enumerateObjectsUsingBlock:^(id  obj, NSUInteger idx, BOOL * _Nonnull stop) {
//        [picArr addObject:[obj valueForKey:@"imgUrl"]];
//        [redirectUrlArr addObject:[obj valueForKey:@"url"]];
//    }];
//
//    imagesURLStrings = (NSArray *)picArr;
//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//        cycleScrollView.imageURLStringsGroup = imagesURLStrings;
//    });
}




@end
